﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ACM.Master" AutoEventWireup="true" CodeBehind="KeyInCarAdvance.aspx.cs" Inherits="ACM.SaleKeyIn" %>

<%@ Register Src="~/UserControls/StatusPanel.ascx" TagPrefix="uc" TagName="StatusPanel" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .my-error-class
        {
            color: #d72728;
            font-size: 12px;
        }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="StatusPlaceHolder" runat="server">
    <uc:StatusPanel ID="Status" runat="server"></uc:StatusPanel>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="server">
    <div class="page-header" style="margin-top: 0;">
        <h1>ลงข้อมูลการขาย</h1>
    </div>

    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <table style="width: 100%; vertical-align: middle;">
                <tr>
                    <td><span style="color: red;">*</span> VIN :</td>
                    <td>
                        <div class="form-group">
                            <asp:TextBox ID="txtVIN" CssClass="form-control" runat="server" MaxLength="17" Width="525" Style="float: left;"></asp:TextBox>
                            <asp:LinkButton ID="lnkCheckVIN" runat="server" CssClass="btn btn-default" OnClick="lnkCheckVIN_Click">Check VIN</asp:LinkButton>
                            <asp:HiddenField ID="hdfCheckVIN" runat="server" />
                            <div id="vinError" style="clear: both"></div>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>รุ่นรถ :</td>
                    <td>
                        <div class="form-group">
                            <asp:TextBox ID="txtSeries" CssClass="form-control" runat="server" Enabled="false" BackColor="White"></asp:TextBox>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>Model :</td>
                    <td>
                        <div class="form-group">
                            <asp:TextBox ID="txtSubSeries" CssClass="form-control" runat="server" Enabled="false" BackColor="White"></asp:TextBox>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>Suffix :</td>
                    <td>
                        <div class="form-group">
                            <asp:TextBox ID="txtModelSuffix" CssClass="form-control" runat="server" Enabled="false" BackColor="White"></asp:TextBox>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>วันที่ตัดขายในระบบ :&nbsp;&nbsp;&nbsp;</td>
                    <td>
                        <div class="form-group">
                            <asp:TextBox ID="txtSaleDate" CssClass="form-control" runat="server" Enabled="false" BackColor="White"></asp:TextBox>
                        </div>
                    </td>
                </tr>                              

                <tr>
                    <td colspan="2" style="text-align: center;">
                        <br />
                        <asp:HiddenField ID="hdf" runat="server" />
                        <asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary" Text="บันทึก" OnClick="btnSave_Click" Enabled="false" />&nbsp;&nbsp;&nbsp;
                        <asp:Button ID="btnClear" runat="server" CssClass="btn btn-default" Text="ล้างข้อมูล" OnClick="btnClear_Click" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="script" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $.validator.addMethod(
                "regex",
                function (value, element, regexp) {
                    var re = new RegExp(regexp);
                    return this.optional(element) || re.test(value);
                },
                "Please check your input."
            );

            $("#form1").validate({
                rules: {
                    ctl00$content$txtVIN: {
                        required: true,
                        regex: "^[0-9a-zA-Z]{17}$"
                    }
                },
                messages: {
                    ctl00$content$txtVIN: {
                        required: "กรุณากรอก VIN",
                        regex: "กรุณากรอก VIN เฉพาะตัวเลขและตัวอักษร 17 ตัวเท่านั้น"
                    }
                },
                errorClass: "my-error-class",
                validClass: "my-valid-class",
                errorPlacement: function (error, element) {
                    error.appendTo($("#vinError"));
                },
            });

            ActiveMenuIndex(1)
        });
    </script>
</asp:Content>
